﻿using Collections.Pooled;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Domain.Shared.Vo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Domain.Shared.Enum
{
    /// <summary>
    /// 楼盘相册图片类型
    /// </summary>
    public enum BuildingPhotoCategoryEnum
    {
        /// <summary>
        /// 效果图
        /// </summary>
        [EnumAttribute(Name = "效果图", Desc = "效果图", Value = "DesignSketch")]
        DesignSketch,
        /// <summary>
        /// 样板图
        /// </summary>
        [EnumAttribute(Name = "样板图", Desc = "样板图", Value = "SampleSketch")]
        SampleSketch,
        /// <summary>
        /// 实景图
        /// </summary>
        [EnumAttribute(Name = "实景图", Desc = "实景图", Value = "RealSketch")]
        RealSketch,
        /// <summary>
        /// 户型图
        /// </summary>
        [EnumAttribute(Name = "户型图", Desc = "户型图", Value = "UnitSketch")]
        UnitSketch,
        /// <summary>
        /// 配套图
        /// </summary>
        [EnumAttribute(Name = "配套图", Desc = "配套图", Value = "MatchingSketch")]
        MatchingSketch,
        /// <summary>
        /// 交通图
        /// </summary>
        [EnumAttribute(Name = "交通图", Desc = "交通图", Value = "TrafficSketch")]
        TrafficSketch,
        /// <summary>
        /// 证照
        /// </summary>
        [EnumAttribute(Name = "证照", Desc = "证照", Value = "LicenceSketch")]
        LicenceSketch,
    }


    public class BuildingPhotoCategory
    {
        public static async Task<PooledSet<NameValueVO>> Items()
        {
            return await Task.Run(() =>
            {
                PooledSet<NameValueVO> ret = new PooledSet<NameValueVO>();
                Type t = typeof(BuildingPhotoCategoryEnum);
                FieldInfo fd = null;
                foreach (var name in t.GetEnumNames())
                {
                    fd = t.GetField(name);
                    var attr = fd.GetCustomAttribute(typeof(EnumAttribute), false) as EnumAttribute;
                    ret.Add(new NameValueVO { Name = attr.Name, Value = attr.Value });
                }
                return ret;
            });
        }
    }


}
